<?php
/**
 * 
 * Empty (空模块)
 *
 * @package      	szflame
 * @author          
 * @copyright     	
 * @license         
 * @version        	szflame企业网站管理系统 v2012.12.12 2011-03-01 198616.com $
 */
if(!defined("szflame")) exit("Access Denied");
class EmptyAction extends Action
{	
	public function _empty()
	{
		//空操作 空模块
		if(MODULE_NAME!='Urlrule'){
			$Mod = F('Mod');			
			if(!$Mod[MODULE_NAME]){ 
				if($_GET['_URL_']){
					$urlArr = $_GET['_URL_'];
				}else{
					$urlArr = $_GET;
				}
				$array_end_param = array_pop($urlArr);
				if(strstr($array_end_param,'detail')){
					//详细页
					$array = explode("_",$array_end_param);
					if($array[0]=='detail' && is_numeric($array[1])){
						$id = $array[1];
						$map['catdir']=array_pop($urlArr);
						if($urlArr){
							$map['parentdir'] = implode("/",$urlArr)."/";
						}
						$cat = M('Category')->where($map)->field('id,module')->order('id desc')->find();
						import('@.Action.Base');
						$bae=new BaseAction(); 
						$bae->show((int)$id,$cat['module']);						
						//echo file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/index.php?m='.$cat['module'].'&a=show&&id='.$id);
						die();
					}
				}else{
					if(strstr($array_end_param,'index') ||strstr($array_end_param,'list_')){
						$array = explode("_",$array_end_param);
						if($array[0] =="list" && is_numeric($array[1])){
							$map['id'] = intval($array[1]);
						}
						if($array[0] =="list" || $array[0] =="index"){
							$array_end_param = array_pop($urlArr);
						}
					}
					//列表页
					if($urlArr){
						$map['parentdir'] = implode("/",$urlArr)."/";
					}
					$map['catdir']=$array_end_param;
					$cat = M('Category')->where($map)->field('id,module')->order('id desc')->find();
					if($cat){
						import('@.Action.Base');
						$bae=new BaseAction();
						$bae->index((int)$cat['id'],$cat['module']);
						//echo file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/index.php?m='.$cat['module'].'&id='.$cat['id']);
						die();
					}else{
						echo file_get_contents('http://'.$_SERVER['HTTP_HOST']);
						die();
					}
				}
				throw_exception('404');
			}
		}

		if(GROUP_NAME=='Admin'){
			R('Admin/Content/'.ACTION_NAME);
		}else{
			$a=ACTION_NAME;
			$id =  intval($_REQUEST['id']);
			$catid = intval($_REQUEST['catid']);
			$moduleid =  intval($_REQUEST['moduleid']);
			if(MODULE_NAME=='Urlrule'){
				if(APP_LANG){
					$lang= $_REQUEST['l'] ? '_'.$_REQUEST['l'] : '_'.C('DEFAULT_LANG');
				}
				if($_REQUEST['catdir']){
					$Cat = F('Cat'.$lang);
					$catid = $catid ? $catid : $Cat[$_REQUEST['catdir']];
					unset($Cat);
				}
				if($_REQUEST['module']){
					$m=$_REQUEST['module'];						
				}elseif($moduleid){
					$Module =F('Module');
					$m=$Module[$moduleid]['module'];
					unset($Module);
				}elseif($catid){
					$Category = F('Category'.$lang);
					$m=$Category[$catid]['module'];
					unset($Category);
				}else{
					throw_exception('404');
				}
				if($a=='index') $id=$catid;
			}else{				
				if(empty($id)){
					$Cat = F('Cat'.$lang);
					$id = $Cat[$_REQUEST['id']];
					unset($Cat);
				}
				$m=MODULE_NAME;			
			}
			import('@.Action.Base');
			$bae=new BaseAction();
			if(!method_exists($bae,$a)){
				throw_exception('404');
			}
			$bae->$a($id,$m);
		}
	}
}
?>